$(document).ready(function () {
  // 侧边栏滑动模块
  (function () {
    var sidebar = $('.sidebar');
    var mask = $('.mask');
    var sidebar_trigger = $('.sidebar_trigger');
    var country = $('.country')
    var countryImg = $('.country-img')
    var showSidebar = function () {
      mask.fadeIn();
      sidebar.animate({ 'right': 0 });
    }
    var hideSidebar = function () {
      mask.fadeOut();
      sidebar.css('right', -sidebar.width());
    }
    sidebar_trigger.bind('click', showSidebar);
    mask.bind('click', hideSidebar);
    sidebar.hover(() => {
    }, () => {
      hideSidebar()
    })
    sidebar_trigger.hover(() => {
      sidebar_trigger.attr('src', './images/file/Property 1=hover.png')
    }, () => {
      sidebar_trigger.attr('src', './images/file/Property 1=default.png')
    })

    var currentL = 'EN'
    // 改变语言
    country.click((event) => {
      if (currentL === 'SV') {
        currentL = 'EN'
        countryImg.attr('src', './images/file/sv 1.png')
      } else {
        currentL = 'SV'
        countryImg.attr('src', './images/file/sv 2.png')
      }
      setLanguage(currentL)
    })
  })();
  //返回顶部模块
  (function () {
    var isPC = function () {
      var userAgentInfo = navigator.userAgent;
      var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPod"];
      var flag = true;
      for (var v = 0; v < Agents.length; v++) {
        if (userAgentInfo.indexOf(Agents[v]) > 0) {
          flag = false;
          break;
        }
      }
      if (window.screen.width >= 768) {
        flag = true;
      }
      return flag;

    };
    console.log(isPC())
    if (isPC()) {
      //如果是PC端，就出现back2top
      $('#longpc').show()
      $('#longmobal').hide()
    } else {
      //如果是移动端，就不需要出现back2top
      $('#longpc').hide()
      $('#longmobal').show()
    }
  })();
  // 招聘信息-下拉手风琴效果
  (function () {
    //全部下拉内容隐藏
    $(".bellows__content-wrapper").hide();
    //默认选中第一个
    $(".bellows__item:eq(1)").addClass("bellows--is-open");
    $(".bellows__content-wrapper:eq(1)").show();
    //点击事件
    $(".bellows__header").click(function () {
      //判断当前tab状态
      if ($(this).parent(".bellows__item").get(0) === $('.bellows--is-open').get(0)) {
        $(this).next().slideUp();//自己关闭
        $(this).parent(".bellows__item").removeClass("bellows--is-open");
      } else {
        $(this).next().slideDown();//内容展开
        $(this).parent(".bellows__item").addClass("bellows--is-open");//父节点增加展开样式
        $(".bellows__header").not(this).next().slideUp();//除了自己其他兄弟都关闭
        $(".bellows__header").not(this).parent(".bellows__item").removeClass("bellows--is-open");//移除其他兄弟父节点的样式
      }
    });
  })();
});
